#!/usr/bin/env bash

set -eu

__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

cd "${__dir}/.."
echo "Current directory is ${PWD}"

CONFIGURATION=debug
export SWIFTCI_IS_SELF_HOSTED=1

set -x

# Perform package update in order to get the latest commits for the dependencies.
swift package update
swift build -c $CONFIGURATION
swift test -c $CONFIGURATION --parallel

# Run the integration tests with just built SwiftPM.
export SWIFTPM_BIN_DIR=$(swift build -c $CONFIGURATION --show-bin-path)
cd IntegrationTests
$SWIFTPM_BIN_DIR/swift-test --parallel
